package calbs.socket.analysis;

import calbs.socket.pojo.req.ReqData;
import calbs.socket.pojo.req.ReqUploadWarningMsg;

/**
 * Created by Q on 2017/8/3.
 */
public class UploadWarningAnalysisImp implements AnalysisI<ReqUploadWarningMsg> {
    @Override
    public ReqData<ReqUploadWarningMsg> analysisMsg(ReqData<ReqUploadWarningMsg> reqData){
        ReqUploadWarningMsg reqUploadWarningMsg = reqData.getBody();
        String content = reqUploadWarningMsg.getContent();
        Integer device = Integer.parseInt(content.substring(0,2*4),16);
        reqUploadWarningMsg.setDevice(device.toString());
        content = content.substring(2*4);
        Integer warningCode = Integer.parseInt(content.substring(0,2*4),16);
        reqUploadWarningMsg.setWarningCode(warningCode.toString());
        content = content.substring(2*4);
        Integer utcTime = Integer.parseInt(content.substring(0,2*4),16);
        reqUploadWarningMsg.setUtcTime(utcTime.toString());
        return reqData;
    }
}
